home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
glass
/
glass.lha
/
GLASS
/
dtm
/
test14.gl
< prev
next >
Wrap
Text File
|
1991-06-18
|
751b
|
34 lines
Basetype E;
Atom
not :- E => E,
nand2 :- E & E => E,
and3 :- E & E & E => E,
or4 :- E & E & E & E => E,
and2 :- E & E => E,
or3 :- E & E & E => E,
div2 :- E => E;
Def
adc :- E & E & E => E & E;
adc [a,b,c] = [s, cout]
where
s = or4 [and3 [not a, not b, c], and3 [not a, b, not c],
and3 [a, not b, not c], and3 [a,b,c]];
cout = or3 [and2 [a,b], and2 [a,c], and2 [b,c]];
endwhere;
Mac
adder :- Int -: n -> E & E^n & E^n => E^n & E;
adder 0 [c, [],[]] = [[], c];
adder n [c, a:as, b:bs] = [s:ss, cout]
where
[s,v] = adc [a,b,c];
[ss, cout] = adder (n-1) [v, as, bs];
endwhere;
Def
adder4 :- E & E^4 & E^4 => E^4 & E;
adder4 [c, as,bs] = adder 4 [c, as,bs];